﻿using System;
using CrazyBeavers.Geodesy;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CrazyBeavers.Geodesy.Projections;

namespace CrazyBeavers.Geodesy.Tests
{
    /// <summary>
    ///This is a test class for GaussKrugerTest and is intended
    ///to contain all GaussKrugerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class GaussKrugerTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Atanh
        ///</summary>
        [TestMethod()]
        [DeploymentItem("CrazyBeavers.Geodesy.dll")]
        public void AtanhTest()
        {
            double d = .7d; // TODO: Initialize to an appropriate value
            double expected = .86730d; // TODO: Initialize to an appropriate value
            double actual;
            actual = GaussKruger_Accessor.Atanh(d);
            Assert.AreEqual(expected, Math.Round(actual, 5));
        }

        /// <summary>
        ///A test for GeodeticToGrid
        ///</summary>
        [TestMethod()]
        public void GeodeticToGridTest()
        {
            GeodeticCoordinate coordinate = new GeodeticCoordinate() { Latitude = 63.90786d, Longitude = 19.75247d };
            Projection projection = SwedishProjections.RT90_25GonV;
            GridCoordinate expected = new GridCoordinate() { X = 7094946, Y = 1693701, Projection = SwedishProjections.RT90_25GonV };
            GridCoordinate actual;
            actual = GaussKruger.GeodeticToGrid(coordinate, projection);
            Assert.IsTrue(expected.Equals(actual));
        }

        /// <summary>
        ///A test for GridToGeodetic
        ///</summary>
        [TestMethod()]
        public void GridToGeodeticTest()
        {
            GridCoordinate coordinate = new GridCoordinate() { X = 7094946, Y=1693701, Projection=SwedishProjections.RT90_25GonV};
            GeodeticCoordinate expected = new GeodeticCoordinate() { Latitude = 63.90786d, Longitude = 19.75247d };
            GeodeticCoordinate actual;
            actual = GaussKruger.GridToGeodetic(coordinate);
            Assert.IsTrue(expected.Equals(actual));
        }
    }
}
